package LeetcodeTest_twenty_eight;
//幂集

import java.util.ArrayList;
import java.util.List;

public class subsets
{
    public static void main(String[] args)
    {
        int[] nums={1,2,3};
        List<List<Integer>> result=new ArrayList<List<Integer>>();
        result=solution.subsets(nums);
        System.out.println(result.size());
    }
}
class solution
{
    public static List<List<Integer>> subsets(int[] nums)
    {
        List<List<Integer>> result=new ArrayList<>();
        ArrayList<Integer> answer=new ArrayList<>();
        int length=nums.length;
        backtrace(result,answer,nums,0);
        return result;
    }
    public static void backtrace(List<List<Integer>> result,ArrayList<Integer> answer,int[] nums,int index)
    {
        result.add(answer.subList(0,answer.size()));
        for(int i=index;i<nums.length;i++)
        {
            answer.add(nums[i]);
            backtrace(result,answer,nums,i+1);
            answer.remove(answer.size()-1);
        }
    }
}